package com.tf_cut.admin.cpm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.tf_cut.admin.annotation.Decrypt;
import com.tf_cut.admin.annotation.Encrypt;
import com.tf_cut.admin.backend.api.BackEndApi;
import com.tf_cut.admin.common.pojo.PageInfo;
import com.tf_cut.admin.common.pojo.Result;
import com.tf_cut.admin.cpm.vo.CpmInsideTransComVo;


@RestController
@RequestMapping("/cpm/")
public class CpmInsideTransController {
	
	@Autowired
	private BackEndApi backEndApi;
	
	// 进入代理商季度未结分润清单页面
	@GetMapping("commission/quarterlist")
    public ModelAndView quarterList() {
        return new ModelAndView("cpm/commission/quarterlist", "cpm", null);
    }
	
	// 代理商季度未结分润清单分页
	@SuppressWarnings("unchecked")
	@PostMapping("commission/quarterlist/page")
	@Decrypt
    @Encrypt
	public Result<PageInfo<CpmInsideTransComVo>> page(CpmInsideTransComVo avo) {
        String json = JSON.toJSONString(avo);
        json = backEndApi.getQuarterCommission(json);
        return JSON.parseObject(json, Result.class);
    }
	
	// 发放/取消 代理商季度未结分润清单。N：发放；D：取消
	@SuppressWarnings("unchecked")
	@PostMapping("commission/quarterlist/payquarter")
	@Decrypt
    @Encrypt
	public Result<String> payQuarter(CpmInsideTransComVo vo) {
        return JSON.parseObject(backEndApi.payQuarter(vo.getIds(), vo.getType()), Result.class);
    }
}
